#include "qelib.h"
#include "qe_driver.h"
#include "libfdt.h"

QELOG_DOMAIN("test3");

static qe_ret test3_probe(const void *fdt, int offset)
{
    int len;
    int node_offset;
    const char *name;
    const char *name_node;
    const char *prop_adda;
    const qe_u32 *prop_irq;

    name = fdt_get_name(fdt, offset, QE_NULL);
    qe_notice("name %s", name);

    prop_irq = fdt_getprop(fdt, offset, "interrupt-parent", &len);
    node_offset = fdt_node_offset_by_phandle(fdt, fdt32_to_cpu(*prop_irq));
    name_node = fdt_get_name(fdt, node_offset, QE_NULL);
    qe_notice("intc %s", name_node);

    qe_notice("intc %s", qe_of_get_interrupt_parent_name(fdt, offset));
    return qe_ok;
}

static const qe_device_id test3_ids[] = {
	{.compatible = "xlnx,zynq-uart",},
    {}
};

QE_DRIVER(test3) = {
    .name = "test3",
    .of_match = test3_ids,
    .probe = test3_probe,
};